package com.heima.feigns.fallback;

import com.heima.feigns.AdminFeign;
import com.heima.feigns.ApUserFeign;
import com.heima.model.admin.pojos.AdChannel;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.user.pojos.ApUser;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class ApUserFeignFallback implements FallbackFactory<ApUserFeign> {
    @Override
    public ApUserFeign create(Throwable throwable) {
        throwable.printStackTrace();
        return new ApUserFeign() {
            @Override
            public ResponseResult<ApUser> findUserById(Integer id) {
                log.error("参数 userId : {}",id);
                log.error("ApUserFeign findUserById 远程调用出错啦 ~~~ !!!! {} ",throwable.getMessage());
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
            }
        };
    }
}